﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Dapper.Core
{
    public class Tools
    {
        /// <summary>
        /// MD5加密字符串处理
        /// </summary>
        /// <param name="Input">待加密码字符串</param>
        /// <returns></returns>
        public static string MD5(string Input)
        {
            return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Input, "MD5").ToLower();
        }

        /// <summary>
        /// 获取真实IP
        /// </summary>
        /// <returns></returns>
        public static string GetRealIP()
        {
            string ip = "";
            try
            {
                HttpRequest request = HttpContext.Current.Request;
                ip = request.UserHostAddress;
            }
            catch
            {
                return "0.0.0.0";
            }
            return ip;
        }
    }
}
